import { observable, action, autorun, toJS } from 'mobx';
import { WeaTableNew, WeaForm } from 'comsMobx';
import * as Apis from './../apis/contact';

export default class ViewContactLogItemStore {
    @observable inputValue = '';
    combj = {};
    @observable contactLoges = [];
    @observable remarks = [];
    @observable show = false;

    @action
    doInit = (combj) => {
      this.combj = combj;
      this.contactLoges = combj.props.item;
      this.remarks = this.contactLoges.remark.datas;
    }
    @action
    updateProps = (props) => {
      this.contactLoges = props.item;
      this.remarks = this.contactLoges.remark.datas;
    }
    @action
    saveRemarkCmd = (params) => {
      if (this.inputValue == '') {
        this.combj.refs.weaError.showError();
        return;
      }
      Apis.saveRemarkCmd({ ...params, text: this.inputValue }).then((result) => {
        this.show = false;
        this.inputValue = '';
        this.getContactLogsRemark();
      });
    }
    @action
    getContactLogsRemark = () => {
      // this.remarks = [];
      // console.log(6666)
      Apis.getContactLogsRemark({ contactid: this.contactLoges.id }).then((result) => {
        this.remarks = result.datas;
        // console.log(this.remarks)
      });
    }
    @action
    setInputValue = (value) => {
      this.inputValue = value;
    }

    @action
    setShow = (show) => {
      this.show = show;
    }
}
